package au.com.handsunited.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import au.com.handsunited.dao.EntityDAO;
import au.com.handsunited.dao.GroupDAO;
import au.com.handsunited.dao.InvitationDAO;
import au.com.handsunited.dao.MessageDAO;
import au.com.handsunited.model.BaseEntity;
import au.com.handsunited.model.Group;
import au.com.handsunited.model.User;
import au.com.handsunited.model.relationship.Role;
import au.com.handsunited.model.relationship.RelationshipStatus;
import au.com.handsunited.model.skill.Skill;
import au.com.handsunited.service.GroupService;

/**
 *
 * @author arunda
 */
public class GroupServiceImpl extends EntityServiceImpl
		implements GroupService {


	private final GroupDAO groupDAO;

	private static Logger logger = LoggerFactory.getLogger(GroupServiceImpl.class);


	/**
	 * @param entityDAO
	 * @param languageDAO TODO
	 * @param messageDAO TODO
	 * @param serviceCategoryDAO TODO
	 * @param skillDAO TODO
	 */
	public GroupServiceImpl(EntityDAO entityDAO, MessageDAO messageDAO, InvitationDAO invitationDAO, GroupDAO groupDAO) {

		super(entityDAO, messageDAO, invitationDAO);
		this.groupDAO = groupDAO;
	}

	/**
	 * @see au.com.handsunited.service.GroupService#addMemberToGroup(au.com.handsunited.model.Group, au.com.handsunited.model.BaseEntity)
	 */
	@Override
	public void addMemberToGroup(Group group, BaseEntity member) {
		addMemberToNetwork(group, member, Role.MEMBER, Role.UNKNOWN, RelationshipStatus.AWAITING_AUTHORISATION, RelationshipStatus.ACTION_PENDING);
	}

	/**
	 * @see au.com.handsunited.service.GroupService#removeMemberFromGroup(au.com.handsunited.model.Group, au.com.handsunited.model.BaseEntity)
	 */
	@Override
	public void removeMemberFromGroup(Group group, BaseEntity member) {
		// TODO Auto-generated method stub

	}


	/**
	 * @see au.com.handsunited.service.GroupService#changeMemberRole(au.com.handsunited.model.Group, au.com.handsunited.model.User, au.com.handsunited.model.User, au.com.handsunited.model.relationship.Role)
	 */
	@Override
	public void changeMemberRole(Group group, User admin, User member, Role newRole) {


	}

	/**
	 * @see au.com.handsunited.service.GroupService#createGroup(au.com.handsunited.model.Group, au.com.handsunited.model.BaseEntity)
	 */
	@Override
	public Group createGroup(Group group, BaseEntity owner) {
		return (Group) createEntity(group, owner);
	}

	/**
	 * @see au.com.handsunited.service.GroupService#deleteGroup(au.com.handsunited.model.Group)
	 */
	@Override
	public boolean deleteGroup(Group group) {
		return false;
	}

	/**
	 * @see au.com.handsunited.service.GroupService#getAllGroups()
	 */
	@Override
	public List<Group> getAllGroups() {
		return groupDAO.getGroups();
	}

	/**
	 * @see au.com.handsunited.service.GroupService#getGroup(java.lang.String)
	 */
	@Override
	public Group getGroup(String groupId) {
		return groupDAO.getGroup(Long.parseLong(groupId));
	}

	/**
	 * @see au.com.handsunited.service.GroupService#searchForGroups(String, java.lang.String)
	 */
	@Override
	public List<Group> searchForGroups(String name, String keywords) {
		return getAllGroups();
	}

	/**
	 * @see au.com.handsunited.service.GroupService#updateOrganisation(au.com.handsunited.model.Group, au.com.handsunited.model.BaseEntity)
	 */
	@Override
	public Group updateOrganisation(Group group, BaseEntity owner) {
		return (Group) updateEntity(group, owner);
	}

	/**
	 * @see au.com.handsunited.service.GroupService#findGroupsWithSkills(java.util.List, boolean)
	 */
	@Override
	public List<Group> findGroupsWithSkills(List<Skill> skills,
			boolean allSkillsRequired) {

		return getAllGroups();
	}

	/**
	 * @see au.com.handsunited.service.GroupService#inviteToGroup(au.com.handsunited.model.Group, au.com.handsunited.model.User, List, java.lang.String, java.lang.String)
	 */
	@Override
	public Map<String, List<String>> inviteToGroup(Group group,
			User invitingUser, List<BaseEntity> invitedEntities, String emailAddresses,
			String message) {
		// TODO Auto-generated method stub
		return null;
	}


}
